﻿<common:LayoutAwarePage x:Name="pageRoot"
                        x:Class="RWSBeeldbank.SearchResults"
                        DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
                        IsTabStop="false"
                        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                        xmlns:local="using:RWSBeeldbank"
                        xmlns:data="using:RWSBeeldbank.Data"
                        xmlns:common="using:RWSBeeldbank.Common"
                        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

                        mc:Ignorable="d" 
                        d:ExtensionType="Search"
                        NavigationCacheMode="Disabled">




    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Style="{StaticResource LayoutRootStyle}"
          Name="LayoutRoot"
          DataContext="{Binding Group}"
          d:DataContext="{Binding AllGroups[0], Source={d:DesignInstance Type=data:SampleDataSource, IsDesignTimeCreatable=True}}">

        <Grid.Resources>
            <CollectionViewSource x:Key="dynamicMediaItems" />
        </Grid.Resources>

        <Grid.RowDefinitions>
            <RowDefinition Height="140" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <!-- Back button and page title -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton"
                    Grid.Column="0"
                    Click="GoBack"
                    Style="{StaticResource BackButtonStyle}" />
            <TextBlock x:Uid="AppName"
                       x:Name="pageTitle"
                       Text="Beeldarchief Rijkswaterstaat"
                       Grid.Column="1"
                       Style="{StaticResource PageHeaderTextStyle}" />
            <TextBlock x:Name="resultText"
                       Grid.Column="2"
                       Text="{Binding ResultText}"
                       Style="{StaticResource PageSubheaderTextStyle}" />
            <TextBlock x:Name="queryText"
                       Grid.Column="3"
                       Text="test"
                       Style="{StaticResource PageSubheaderTextStyle}" />
        </Grid>


        <Grid x:Name="resultsPanel"
        Grid.Row="1">
            <!--
    The body of the page in most view states uses an items controls to create multiple radio buttons
    for filtering above a horizontal scrolling grid of search results
-->
            <Grid x:Name="typicalPanel">

                <!-- Horizontal scrolling grid used in most view states -->
                <GridView x:Name="resultsGridView"
                  AutomationProperties.AutomationId="resultsGridView"
                  AutomationProperties.Name="Search Results"
                  TabIndex="1"
                  Grid.Row="1"
                  Margin="0,2,0,0"
                  Padding="110,0,110,46"
                  ItemsSource="{Binding Source={StaticResource dynamicMediaItems}}"
                  ItemTemplate="{StaticResource StandardSmallIcon300x70ItemTemplate}"
                  SelectionMode="None"
                  IsItemClickEnabled="True"
                  ItemClick="ItemView_ItemClick">


                    <GridView.ItemContainerStyle>
                        <Style TargetType="Control">
                            <Setter Property="Height"
                                    Value="70" />
                            <Setter Property="Margin"
                                    Value="0,0,38,8" />
                        </Style>
                    </GridView.ItemContainerStyle>

                    <GridView.ItemContainerTransitions>
                        <TransitionCollection>
                            <AddDeleteThemeTransition />
                        </TransitionCollection>
                    </GridView.ItemContainerTransitions>

                </GridView>
            </Grid>

            <!--
    The body of the page when snapped uses a combo box to select a filter above a
    vertical scrolling list of search results
-->
            <Grid x:Name="snappedPanel" Visibility="Collapsed">

                <ListView x:Name="resultsListView"
                          AutomationProperties.AutomationId="ResultsListView"
                          AutomationProperties.Name="Search Results"
                          TabIndex="1"
                          Grid.Row="1"
                          Margin="16,0,0,0"
                          Padding="0,0,0,60"
                          SelectionMode="None"
                          IsItemClickEnabled="True"
                          ItemsSource="{Binding Source={StaticResource dynamicMediaItems}}"
                          ItemTemplate="{StaticResource StandardSmallIcon70ItemTemplate}"
                          ItemClick="ItemView_ItemClick">

                    <ListView.ItemContainerStyle>
                        <Style TargetType="Control">
                            <Setter Property="Height"
                                    Value="70" />
                            <Setter Property="Margin"
                                    Value="0,0,18,8" />
                        </Style>
                    </ListView.ItemContainerStyle>


                    <ListView.ItemContainerTransitions>
                        <TransitionCollection>
                            <AddDeleteThemeTransition />
                        </TransitionCollection>
                    </ListView.ItemContainerTransitions>


                </ListView>
            </Grid>
        </Grid>

        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape" />
                <VisualState x:Name="Filled" />

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton"
                                                       Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="{StaticResource PortraitBackButtonStyle}" />
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!--
                    The back button and title have different styles when snapped, and the list representation is substituted
                    for the grid displayed in all other view states
                -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton"
                                                       Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="{StaticResource SnappedBackButtonStyle}" />
                        </ObjectAnimationUsingKeyFrames>

                        
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="queryText"
                                                       Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="{StaticResource SnappedPageHeaderTextStyle}" />
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle"
                                                       Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="Collapsed" />
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="resultText"
                                                       Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="Collapsed" />
                        </ObjectAnimationUsingKeyFrames>


                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="typicalPanel"
                                                       Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="Collapsed" />
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="snappedPanel"
                                                       Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0"
                                                    Value="Visible" />
                        </ObjectAnimationUsingKeyFrames>


                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</common:LayoutAwarePage>
